/*竞赛获奖信息统计 */
<template>
    <div>
        <div v-if="indexKey === 1">
            <condition-card
                label-position="right"
                label-width="150px"
                @reset="reset"
                @search="onSubmit"
            >
                <el-row style="height: 50px;">
                     <!-- 获奖等级 -->
                    <el-col :span="8">
                        <el-form-item :label="$t('statisticsOfAwards.awardName')">
                            <el-select
                                v-model="queryForm.condition.awardsName"
                                clearable
                                style="width: 100%">
                                <el-option
                                    v-for="item in options.prize"
                                    :key="item.id"
                                    :label="item.label"
                                    :value="item.label">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <!-- 竞赛项目名称 -->
                    <el-col :span="8">
                        <el-form-item :label="$t('statisticsOfAwards.competitionNames')">
                            <!-- <el-select collapse-tags  v-model="queryForm.condition.projectName"  filterable clearable  style="width: 100%">
                                 <el-option  v-for="item in options.profession" :key="item.code" :label="item.label" :value="item.value"></el-option>
                            </el-select> -->
                            <el-input
                                v-model="queryForm.condition.projectName"
                                :placeholder="$t('statisticsOfAwards.pleaseEnter')"
                                clearable
                                style="width: 100%">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <!-- 竞赛级别 -->
                    <el-col :span="8">
                        <el-form-item :label="$t('statisticsOfAwards.competitionLevel')">
                            <el-select
                                v-model="queryForm.condition.comLevel"
                                clearable
                                style="width: 100%">
                                <el-option
                                    v-for="item in options.batch"
                                    :key="item.id"
                                    :label="item.label"
                                    :value="item.label">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>

                </el-row>
                <el-row>
                    <!-- 获奖人员 -->
                    <el-col :span="8">
                        <el-form-item :label="$t('statisticsOfAwards.winners')">
                            <el-input
                                v-model="queryForm.condition.studentId"
                                :placeholder="$t('statisticsOfAwards.pleaseInputJobNumberOrName')">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <!-- 获奖时间 -->
                    <!-- <el-col :span="8"> -->

                      <!-- <el-form-item :label="$t('statisticsOfAwards.awardTime')"> -->
                    <el-col :span="8">
                        <el-form-item :label="$t('statisticsOfAwards.awardTime')">
                            <el-date-picker
                            :picker-options="pickerOptionsStart"
                            type="month"
                            :placeholder="$t('statisticsOfAwards.pleaseSelect')"
                             v-model="queryForm.condition.awardsDateStart"
                            value-format="yyyy-MM"
                            style="width: 100%;"></el-date-picker>
                        </el-form-item>
                    </el-col>
                        <!-- <el-col class="line" :span="0.1">-</el-col> -->
                        <!-- <el-col :span="2">
                        <el-form-item>
                            <el-date-picker
                            :picker-options="pickerOptionsEnd"
                             type="month"
                              :placeholder="$t('statisticsOfAwards.awardsDateEnd')"
                               v-model="queryForm.condition.awardsDateEnd"
                               style="width: 100%;"></el-date-picker>
                        </el-form-item>
                        </el-col> -->
                    <!-- </el-form-item> -->
                    <!-- </el-col> -->
                    <!-- 竞赛形式 -->
                    <el-col :span="8">
                        <el-form-item :label="$t('statisticsOfAwards.competitionForm')">
                            <el-select
                                v-model="queryForm.condition.comForm"
                                clearable
                                style="width: 100%">
                                <el-option
                                    v-for="item in options.match"
                                    :key="item.id"
                                    :label="item.label"
                                    :value="item.label">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="2">
                        <el-form-item :label="$t('statisticsOfAwards.awardTime')">
                            <el-date-picker
                                v-model="queryForm.condition.awardsDateStart"
                                type="month"
                                :placeholder="$t('statisticsOfAwards.awardsDateStart')">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col class="line" style="margin-left:30px" :span="1">
                        至
                    </el-col>
                    <el-col :span="2">
                        <el-form-item>
                            <el-date-picker
                                v-model="queryForm.condition.awardsDateEnd"
                                type="month"
                                :placeholder="$t('statisticsOfAwards.awardsDateEnd')">
                            </el-date-picker>
                        </el-form-item>
                    </el-col> -->
                    <!-- <div class="block">
                        <span class="demonstration">默认</span>
                        <el-date-picker
                            v-model="value1"
                            type="monthrange"
                            align="right"
                            unlink-panels
                            range-separator="至"
                            start-placeholder="开始月份"
                            end-placeholder="结束月份"
                        />
                    </div> -->
                </el-row>
                <el-row>
                    <!-- 年级 -->
                    <el-col :span="8">
                        <el-form-item :label="$t('statisticsOfAwards.grade')">
                            <el-date-picker
                                v-model="queryForm.condition.grade"
                                value-format="yyyy"
                                type="year"
                                :placeholder="$t('placeholderTips.selectGrade')"
                                style="width:100%"
                            >
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <!-- 学院 -->
                    <el-col :span="8">
                        <el-form-item :label="$t('label.college')">
                            <DictSelect :labelAll="$t('statisticsOfAwards.whole')" v-model="queryForm.condition.college" filterable :data="options.college" :clearable="true" ></DictSelect>
                        </el-form-item>
                    </el-col>
                    <!-- 是否立项 -->
                    <el-col :span="8">
                        <el-form-item :label="$t('statisticsOfAwards.projectApprovalOrNot')">
                            <el-select
                                v-model="queryForm.condition.setUp"
                                clearable
                                style="width: 100%">
                                <el-option
                                    v-for="item in setUp"
                                    :key="item.id"
                                    :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <!-- 是否手动添加 -->
                    <el-col :span="8">
                        <el-form-item label="是否手动添加">
                            <el-select
                                v-model="queryForm.condition.manual"
                                clearable
                                style="width: 100%">
                                <el-option
                                    v-for="item in setTimer"
                                    :key="item.id"
                                    :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
            </condition-card>

            <el-card
                v-loading="loading"
                shadow="never"
                body-style="padding: 24px;"
                class="card-margin"
            >
                <h1 class="condition-title">{{ $t('statisticsOfAwards.statisticalListOfAwards') }}</h1>
                <el-row style="padding:15px;" type="flex" class="row-bg" justify="end">
                    <!-- <el-dropdown placement='bottom-start' trigger="click" @command="downloadFile">
                        <el-button type="primary">{{$t('internship.lead')}}<i class="el-icon-arrow-down el-icon--right"></i></el-button>
                        <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item command="导入">{{$t('导入数据')}}</el-dropdown-item>
                        <el-dropdown-item command="下载">{{$t('internship.download')}}</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown> -->
                    <!-- v-premit="'set_addtime'" -->
                    <el-button v-premit="'set_addtime'" type="primary" style="float:right; margin-left:10px;" @click="setTimeBtn" >设置手动添加时间</el-button>
                    <el-button type="primary" style="float:right; margin-left:10px;" @click="statistic">{{ $t('statisticsOfAwards.awardStatistics') }}</el-button>
                    <el-button type="primary" style="float:right; margin-left:10px;" @click="add">{{ $t('statisticsOfAwards.adds') }}</el-button>
                    <el-button  type="primary" style="float:right; margin-left:10px;"  @click="exportFile">{{ $t('statisticsOfAwards.export') }}</el-button>
                    <el-upload
                        class="upload-demo"
                        action="/api/competitionservice/manage/manageprojectawardsinfo/importAwardsInfo"
                        :on-success="changeSuccess"
                        :auto-upload="true"
                        :imit="1"
                        :before-upload='changeUpload'
                        :file-list="fileList"
                        style="display: none;"
                        >
                        <span slot="trigger" ref="importBtn">{{$t('statisticsOfAwards.importFile')}}</span>

                    </el-upload>
                </el-row>
                <el-table
                    :pagination="false"
                    :selection="false"
                    :tooltip-effect="tooltipEffect"
                    :data="dataList"
                    :order="false"
                    border
                    stripe
                    size="mini"
                    @selection-change="handleSelectionChange"
                    :span-method="objectSpanMethod"
                >
                    <el-table-column :label="$t('statisticsOfAwards.competitionName')" prop="projectName" show-overflow-tooltip></el-table-column>
                    <el-table-column :label="$t('statisticsOfAwards.organStructure')" prop="orgName" show-overflow-tooltip></el-table-column>
                    <el-table-column :label="$t('statisticsOfAwards.competitionLevel')" prop="comLevel" show-overflow-tooltip></el-table-column>
                    <el-table-column :label="$t('label.college')" prop="collegeName" show-overflow-tooltip></el-table-column>
                    <el-table-column :label="$t('statisticsOfAwards.projectApprovalOrNot')" prop="setUp" show-overflow-tooltip></el-table-column>
                    <el-table-column :label="$t('statisticsOfAwards.awardTime')" prop="awardsDate" show-overflow-tooltip></el-table-column>
                    <el-table-column :label="$t('statisticsOfAwards.competitionTeam')" prop="comForm" min-width="100" show-overflow-tooltip></el-table-column>
                    <el-table-column :label="$t('statisticsOfAwards.awardLevel')" prop="awardsName" show-overflow-tooltip></el-table-column>
                    <el-table-column :label="$t('statisticsOfAwards.titleOfTheWork')" prop="projectTitle" show-overflow-tooltip></el-table-column>
                    <el-table-column align='center' :label="$t('statisticsOfAwards.informationOfWinners')" show-overflow-tooltip>
                        <el-table-column :label="$t('statisticsOfAwards.groups')" prop="termNumber" show-overflow-tooltip></el-table-column>
                        <el-table-column :label="$t('statisticsOfAwards.studentId')" prop="studentId" show-overflow-tooltip></el-table-column>
                        <el-table-column :label="$t('statisticsOfAwards.studentName')" prop="studentName" show-overflow-tooltip></el-table-column>
                    </el-table-column>
                    <el-table-column :label="$t('statisticsOfAwards.instructor')" prop="instructor" show-overflow-tooltip></el-table-column>
                </el-table>

                <el-row type="flex" class="row-bg" justify="end">
                    <el-col>
                        <el-pagination
                            :current-page="queryForm.pageNum_"
                            :page-sizes="[20, 40, 80, 100]"
                            :page-size="queryForm.pageSize_"
                            :total="queryForm.total_"
                            layout="total, sizes, prev, pager, next, jumper"
                            style="float:right;margin-top:10px"
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                        >
                        </el-pagination>
                    </el-col>
                </el-row>
            </el-card>
            <edu-export-dialog
                ref="downloadRef"
                :disabled="exportButton"
                :title="$t('message.prompt')"
                :data="exportResult"
            >
            </edu-export-dialog>
        </div>
        <!-- 新增 -->
        <div v-if="indexKey === 2">
            <competiInformaAdd
                :compile="compile"
                :data-list="dataListObj"
                @change-exam="changeExam"
            >
            </competiInformaAdd>
        </div>
        <!-- 获奖统计 -->
        <div v-if="indexKey === 3">
            <awardStatistic
                :compile="compile"
                :data-list="dataListObj"
                @change-exam="changeExam"
            >
            </awardStatistic>
        </div>
        <!-- 弹框 -->
      <edu-dialog title="设置手动添加时间" width="600px" ref="updateDialog" :auto-height="true" @close="resetAddForm">
        <el-form :model="createForm" ref="createForm" label-width="120px" label-suffix=":">
          <el-row>
            <el-col :span="12">
              <el-form-item label="添加时间" prop="timeVlaue" :rules="[
                  { required: true, message: $t('message.inputRequired'), trigger: 'blur' }
                ]">
                <el-date-picker
                  v-model="createForm.timeVlaue"
                  value-format="yyyy-MM-dd"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <span slot="buttons">
          <el-button @click="close(createForm)">{{$t('message.cancel')}}</el-button>
          <el-button @click="submitFormcode()" type="primary">保存</el-button>
        </span>
      </edu-dialog>
    </div>
</template>

<script>
import { queryDic } from 'common/src/api/dictionary'
import UTILS from 'common/src/utils/utils'
import competiManagementApi from 'common/src/api/subjectCompetition/competiManagement'
import compeAdd from './competiInformAdd'
import awardStatistic from './awardStatistic'
export default {
    components: {
        competiInformaAdd: compeAdd,
        awardStatistic: awardStatistic
    },
    data() {
        return {
            createForm: {
              timeVlaue:''
            },
            value1: '',
            importConference: false,
            ifErr: false,
            fileList: [],
            errList: [],
            queryForm: {
                pageNum_: 1,
                pageSize_: 20,
                total_: 0,
                condition: {
                    awardsName: '',
                    projectName: '', // 竞赛项目名称
                    comLevel: '', // 竞赛级别
                    studentId: '', // 获奖人员
                    // projId: '',
                    awardsDateStart: '', // 获奖时间(开始)
                    awardsDateEnd: '', //获奖时间(结束)
                    comForm: '', //竞赛形式
                    grade: '', // 年级
                    college: '', // 学院
                    setUp: null, // 是否立项 0 否 1 是
                    manual:''//是否手动添加
                }
            },
            dataListObj: {},
            dataList: [],
            exportButton: false,
            exportResult: null,
            indexKey: 1,
            compile: '',
            options: {
                // profession: [], // 竞赛项目名称
                batch: [], // 竞赛级别
                match: [], // 参赛形式
                prize: [], // 奖项名称
                college: [] // 学院
            },
            setUp: [
                {
                    value: 0,
                    label: '否'
                }, {
                    value: 1,
                    label: '是'
                }
            ],
              setTimer: [
                {
                    value: 0,
                    label: '否'
                }, {
                    value: 1,
                    label: '是'
                }
            ],
            pickerOptionsStart: {
                disabledDate: time => {
                let endDateVal = this.queryForm.condition.awardsDateEnd;
                    if (endDateVal) {
                        return time.getTime() > endDateVal;
                        // return time.getTime() >= new Date(endDateVal).getTime();
                    }
                }
            },
            pickerOptionsEnd: {
                disabledDate: time => {
                let beginDateVal = this.queryForm.condition.awardsDateStart;
                if (beginDateVal) {
                    // return time.getTime() < beginDateVal;
                    return time.getTime() <= new Date(beginDateVal).getTime()- 86400000;
                }
                }
            },
            spanArr: [], // 一个空的数组，用于存放每一行记录的合并数
            pos: 0, // spanArr 的索引
            contentSpanArr: [],
            position: 0,
            timeid:''
        }
    },
    mounted() {
        //进入页面根据本科生和研究生判
        // let user =
        //     this.$store.state.session.user ||
        //     JSON.parse(localStorage.getItem("user"));
        // if (user) {
        //     this.queryForm.condition.projId = user.currentManageDptId === '1' ? 1 : 2;
        // }
        this.getOptions()
        this.postCompetitionInform(this.queryForm)
    },
    methods: {
      submitFormcode(){
        this.$refs.createForm.validate(valid => {
          var obj={
            startTime:this.createForm.timeVlaue[0]+' 00:00:00',
            endTime:this.createForm.timeVlaue[1]+' 23:59:59',
            id:this.timeid
          }
          if (valid) {
              competiManagementApi.setTimeapi(obj).then(res => {
                    if (res.code == 200) {
                        this.close();
                    } else {
                    }
                })
          }
        })
      },
      close(data) {
        this.createForm.timeVlaue='';
        this.$refs.updateDialog.close();
      },
        //时间详情
        setTimeBtn(){
          this.createForm.timeVlaue='';
          competiManagementApi.setTimeDel().then(res => {
                if (res.code == 200) {
                    this.timeid=res.data.id?res.data.id:'';
                    let t1=res.data.startTime.split(" ")[0];
                    let t2=res.data.endTime.split(" ")[0];
                    var arr=[];
                    arr.push(t1);
                    arr.push(t2);
                    this.$set(this.createForm,'timeVlaue',arr)
                } else {
                }
            })
          this.$refs.updateDialog.open();
        },
        // 字典获取
        getOptions() {
            // 筛选条件字典查询
            let data = {
                lang: this.$store.getters.language || 'cn',
                type: 'allChild',
                keys: ['X_PYCC', 'X_PYLB', 'X_XWLX', 'X_XXXS', 'X_YX', 'JSGL_JSJB', 'JSGL_JXMC', 'JSGL_CSXS']
            }
            queryDic(data).then(res => {
                UTILS.fillSelect(
                    {
                        trainingCategory: 'X_PYLB',
                        // degreeType: 'X_XWLX',
                        formLearning: 'X_XXXS',
                        college: 'X_YX',
                        TrainingLevel: 'X_PYCC',
                        batch: 'JSGL_JSJB',
                        match: 'JSGL_CSXS',
                        prize: 'JSGL_JXMC'
                    },
                    res.data,
                    this.options
                )

            })
        },
        // 合并单元格
        objectSpanMethod({ row, column, rowIndex, columnIndex }) {
            if (columnIndex === 0 || columnIndex === 1 || columnIndex === 2 || columnIndex === 3 || columnIndex === 4 || columnIndex === 5 || columnIndex === 6 || columnIndex === 7 || columnIndex === 8) {
                const _row = this.spanArr[rowIndex]
                const _col = _row > 0 ? 1 : 0
                return {
                    rowspan: _row,
                    colspan: _col
                };
            } else if (columnIndex === 11) {
                const _row = this.contentSpanArr[rowIndex]
                const _col = _row > 0 ? 1 : 0
                return {
                    rowspan: _row,
                    colspan: _col
                };
            }
        },
        postCompetitionInform(data) {
            competiManagementApi.getPageList(data).then(res => {
                this.dataList = res.data.list
                this.queryForm.total_ = res.data.total_
                // 设定一个数组spanArr/contentSpanArr来存放要合并的格数，同时还要设定一个变量pos/position来记录
                this.spanArr = []
                this.contentSpanArr = []
                for (var i = 0; i < this.dataList.length; i++) {
                    if (i === 0) {
                        this.spanArr.push(1)
                        this.pos = 0
                        this.contentSpanArr.push(1)
                        this.position = 0
                    } else {
                        // 判断当前元素与上一个元素是否相同(第1和第2列)
                        if (this.dataList[i].comForm === '团队' && this.dataList[i - 1].comForm === '团队'
                            && this.dataList[i].awardsDate === this.dataList[i - 1].awardsDate
                            && this.dataList[i].awardsName === this.dataList[i - 1].awardsName
                            && this.dataList[i].comLevel === this.dataList[i - 1].comLevel
                            && this.dataList[i].orgName === this.dataList[i - 1].orgName
                            && this.dataList[i].projectName === this.dataList[i - 1].projectName
                            && this.dataList[i].projectTitle === this.dataList[i - 1].projectTitle) {
                            this.spanArr[this.pos] += 1
                            this.spanArr.push(0)
                        } else {
                            this.spanArr.push(1)
                            this.pos = i
                        }
                        // 判断当前元素与上一个元素是否相同(第3列)
                        if (this.dataList[i].comForm === '团队' && this.dataList[i - 1].comForm === '团队'
                            && this.dataList[i].awardsDate === this.dataList[i - 1].awardsDate
                            && this.dataList[i].awardsName === this.dataList[i - 1].awardsName
                            && this.dataList[i].comLevel === this.dataList[i - 1].comLevel
                            && this.dataList[i].orgName === this.dataList[i - 1].orgName
                            && this.dataList[i].projectName === this.dataList[i - 1].projectName
                            && this.dataList[i].projectTitle === this.dataList[i - 1].projectTitle) {
                            this.contentSpanArr[this.position] += 1
                            this.contentSpanArr.push(0)
                        } else {
                            this.contentSpanArr.push(1)
                            this.position = i
                        }
                    }
                }
            })
        },
        // 筛选
        onSubmit() {
            this.queryForm.pageNum_ = 1
            this.postCompetitionInform(this.queryForm)
        },
        // 重置
        reset() {
            for (let key in this.queryForm.condition) {
                if (key === 'projId') {
                    continue;
                }
                this.queryForm.condition[key] = '';
            }
            this.queryForm.pageNum_ = 1
            this.postCompetitionInform(this.queryForm)
        },
        changeUpload(file) {
            // && !file.name.endsWith(".xls")
            if (!file.name.endsWith(".xlsx")){
                this.fileList = [];
                return this.$message.warning(this.$t('cetStatistics.formatError'))
            }
        },
        changeSuccess(res, file, fileList) {
            if (res.code === 200) {
                this.$message({type: "success", message: this.$t('internship.successfully')});
                this.importConference = false
                this.queryForm.pageNum_ = 1
                this.postCompetitionInform(this.queryForm)
            } else {
                this.fileList = []
                if (res.data) {
                this.errList = res.data
                this.ifErr = true
                this.$message({type: "info", message: this.$t('statisticsOfAwards.addedFully')});
                } else {
                this.$message({type: "info", message: res.msg});
                }
            }

        },
        // 导入
        leadFile(command) {
            if (command === '导入') {
                this.importConference = true
                this.$refs.importBtn.click();
                this.errList = []
                this.ifErr = false
            }
        },
        downloadFile(command) {
            if (command === '导入') {
                this.importConference = true
                this.errList = []
                this.ifErr = false
            } else if (command === '下载') {
                competiManagementApi.getImportTemplate().then(res => {
                this.importConference = false
                this.$message.success(this.$t('internship.successfully'));
                });
            }
        },
        // 轮询直到获取key值的接口返回
        cycleToGetKey() {
            // setTimeout(() => {
                // let currentIds = [];
                // if (this.multipleSelection.length > 0) {
                //   this.multipleSelection.forEach((element) => {
                //     currentIds.push(element.id);
                //   });
                // }
                competiManagementApi.awardInfoExport(this.queryForm)
            // }, 3000)
        },
        // 导出异步
        delayRequest(key, name) {
            setTimeout(() => {
                competiManagementApi.downloadGetKey(key, name).then(res => {
                    this.exportResult = res.data
                    if (res.code === 200 && res.data.status) {
                        this.exportButton = false
                        let path =
                            '/api/competitionservice/competitionExport/file?path=' +
                            res.data.path +
                            '&name=' +
                            name
                        // window.open(path);
                        window.location.href = path
                        this.$message.success(this.$t('result.exportSuccessfully'))
                        this.$refs.downloadRef.close()
                    } else {
                        this.delayRequest(key, name)
                    }
                })
            }, 3000)
        },
        // Normal导出异步
        normalDelayRequest(key, name) {
            setTimeout(() => {
                competiManagementApi.downloadGetKey(key).then(res => {
                    this.exportResult = res.data
                    if (res.code === 200 && res.data.status) {
                        this.exportButton = false
                        let path =
                            '/api/competitionservice/competitionExport/file?path=' +
                            res.data.path +
                            '&name=' +
                            name
                        window.location.href = path
                        this.$message.success(this.$t('result.exportSuccessfully'))
                        this.$refs.downloadRef.close()
                    } else {
                        this.delayRequest(key, name)
                    }
                })
            }, 3000)
        },
        // 导出
        exportFile() {
            // 1、第一步：调该接口，获取key值以及msg中的文件名
            // 2、第二步：将key值放入接口传参
            // 3、第三步：传入path值以及name(msg中的文件名)值，下载文件
            // this.exportResult = null
            // this.$refs.downloadRef.open()
            // this.exportButton = true
            // this.cycleToGetKey()
            let param = {
                "awardsName": this.queryForm.condition.awardsName,
                "projectName": this.queryForm.condition.projectName,
                "comLevel": this.queryForm.condition.comLevel,
                "studentId": this.queryForm.condition.studentId,
                "comForm": this.queryForm.condition.comForm,
                "projId": this.queryForm.condition.projId,
                "awardsDateStart": this.queryForm.condition.awardsDateStart,
                "awardsDateEnd": this.queryForm.condition.awardsDateEnd,
                "manual": this.queryForm.condition.manual
            }
            competiManagementApi.awardInfoExport(param)
        },
        // 新增
        add() {

              competiManagementApi.setTimeDel().then(res => {
                if (res.code == 200) {
                    this.timeid=res.data.id?res.data.id:'';
                    var timestampB=new Date().getTime();//本地
                    let t2=res.data.startTime;
                    let t3=res.data.endTime;
                    var timestampStart=new Date(t2).getTime();
                    var timestampEnd=new Date(t3).getTime();
                    if(t3){
                      var timeEnd=t3.split(' ')[0];
                    }
                    if(res.data.startTime){
                      var timeStart=res.data.startTime.split(' ')[0];
                    }
                    if(t3){
                        if(timestampB<timestampStart||timestampB>timestampEnd){
                        this.$message({
                            type: 'warning',
                            message: `当前不在可添加时间内，请联系管理员！可添加时间为：${timeStart} - ${timeEnd}`,
                        })
                        return
                      }else{
                          this.compile = this.$t('statisticsOfAwards.adds')
                          this.indexKey = 2
                      }
                    }else{
                        this.$message({
                            type: 'warning',
                            message: '请先设置手动添加时间！',
                        })
                        return
                    }

                } else {
                }
            })

            
        },
        // 获奖统计
        statistic() {
            this.compile = this.$t('statisticsOfAwards.awardStatistics')
            this.indexKey = 3
        },
        // 返回列表主页
        changeExam() {
            this.indexKey = 1
            this.queryForm.pageNum_ = 1
            this.postCompetitionInform(this.queryForm)
        },
        collegeChange() {},
        handleSelectionChange() {},
        // 分页
        handleSizeChange(val) {
            this.queryForm.pageSize_ = val
            this.queryForm.pageNum_ = 1
            this.postCompetitionInform(this.queryForm)
        },
        // 分页
        handleCurrentChange(val) {
            this.queryForm.pageNum_ = val
            this.postCompetitionInform(this.queryForm)
        }
    }
}
</script>

<style></style>
